package com.example.teamilkmall.controller;

import com.example.teamilkmall.controller.vo.ResultVO;
import com.example.teamilkmall.entity.ProductTypeInfo;
import com.example.teamilkmall.service.ProductTypeInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2025-01-07
 */
@RestController
@RequestMapping("/productTypeInfo")
public class ProductTypeInfoController extends BaseController{
    
    private final ProductTypeInfoService productTypeInfoService;

    public ProductTypeInfoController(ProductTypeInfoService productTypeInfoService) {
        this.productTypeInfoService = productTypeInfoService;
    }

    @GetMapping("/productTypeInfo")
    public ResultVO<PageInfo<ProductTypeInfo>> listAdmin(Integer limit, Integer page, String name){
        PageInfo<ProductTypeInfo> pageInfo = productTypeInfoService.listProductTypeInfo(limit, page, name);
        return success(pageInfo);
    }

    @PostMapping("/updateProductTypeInfo")
    public ResultVO updateAdmin(ProductTypeInfo admin){
        productTypeInfoService.updateProductTypeInfo(admin);
        return success();
    }

    @PostMapping("/deloneProductTypeInfo")
    public ResultVO deloneAdmin(Integer id){
        productTypeInfoService.deloneProductTypeInfo(id);
        return success();
    }

    @PostMapping("/addProductTypeInfo")
    public ResultVO addAdmin(ProductTypeInfo admin){
        productTypeInfoService.addProductTypeInfo(admin);
        return success();
    }

    @PostMapping("/listProductTypeInfoAll")
    public ResultVO<List<ProductTypeInfo>> getAdminList(){
        return success(productTypeInfoService.getListProductTypeInfo());
    }

}
